package com.yeyks.app.controller.base.hotel;

import com.github.pagehelper.PageInfo;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.convert.DateEditor;
import com.yeyks.commonReference.service.hotel.HotelSearchJipService;
import com.yeyks.hotel.dal.domain.HotelRecommend;
import com.yeyks.hotel.dal.domain.HotelRecommendCity;
import com.yeyks.hotel.dto.HotelInfoC2bHotelVipSearchDto;
import com.yeyks.hotel.param.HotelSearchJipAppendNewHotelListParam;
import com.yeyks.hotel.param.HotelSearchJipAppendPageListParam;
import com.yeyks.hotel.service.HotelRecommendCityService;
import com.yeyks.hotel.service.HotelRecommendService;
import com.yeyks.other.dal.domain.Carousel;
import com.yeyks.other.service.CarouselService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@Api(tags = "酒店搜索精选接口", description = "酒店搜索精选接口")
@Slf4j
@RestController
@RequestMapping(value = "/app/hotel/jip")
public class HotelSearchJipAppendController {

    @InitBinder
    public void initbinder(WebDataBinder webDataBinder) {
        webDataBinder.registerCustomEditor(Date.class, new DateEditor());
    }

    @Autowired
    private CarouselService carouselService;
    @Autowired
    private HotelRecommendService hotelRecommendService;
    @Autowired
    private HotelRecommendCityService hotelRecommendCityService;
    @Autowired
    private HotelSearchJipService hotelSearchJipService;

    @ApiOperation(value = "jip轮播图:v4.0.0")
    @RequestMapping(value = "/carousel/list", method = RequestMethod.POST)
    public AjaxResponseBody<List<Carousel>> carouselList() {
        return AjaxResponseBody.success(carouselService.myList(0, 1));
    }

    @ApiOperation(value = "推荐酒店:v4.3.0")
    @RequestMapping(value = "/recommended/city/list", method = RequestMethod.POST)
    public AjaxResponseBody<List<HotelRecommendCity>> recommendedCityList() {
        return AjaxResponseBody.success(hotelRecommendCityService.list());
    }

    @ApiOperation(value = "推荐酒店:v4.3.0")
    @RequestMapping(value = "/recommended/hotel/list", method = RequestMethod.POST)
    public AjaxResponseBody<PageInfo<HotelRecommend>> recommendedHotelList(HotelSearchJipAppendPageListParam param) {
        return AjaxResponseBody.success(hotelRecommendService.pageList(param));
    }

    @ApiOperation(value = "最新上新:v4.4.3")
    @RequestMapping(value = "/new/hotel/list", method = RequestMethod.POST)
    public AjaxResponseBody<PageInfo<HotelInfoC2bHotelVipSearchDto>> newHotelList(@Validated HotelSearchJipAppendNewHotelListParam param) {
        return AjaxResponseBody.success(hotelSearchJipService.newHotelList(param));
    }

}
